home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 February: Tool Chest / Dev.CD Feb 99 TC.toast / What's New? / Development Kits / Mac OS USB v1.1f3 DDK / Examples / PrinterClassDriver / DRVRGlue.a < prev    next >
Encoding:
Text File  |  1999-01-07  |  2.5 KB  |  97 lines  |  [TEXT/MPS ]

  1. ;
  2. ;    File:        DRVRGlue.a
  3. ;
  4. ;    Contains:    DRVR interface
  5. ;
  6. ;    Copyright:     1998 by Apple Computer, Inc., all rights reserved.
  7. ;
  8. ;
  9.  
  10.         
  11.     BLANKS    ON
  12.     STRING    ASIS
  13.         
  14.     INCLUDE        'LowMem.a'
  15.     INCLUDE        'Devices.a'
  16. ;
  17. ;    for an explanation of VMimmune and gestalt see AsyncDriverSample 1.0b4
  18. ;
  19. dVMImmuneMask                EQU    $0001
  20. dDriverGestaltEnableMask    EQU    $0004    ; See DriverGestalt.h
  21.  
  22. drvrFlags        EQU    dReadEnableMask +  dWritEnableMask + dCtlEnableMask +  dStatEnableMask
  23. drvrSystemFlags    EQU dNeedLockMask
  24.  
  25. DRVREntry        MAIN    EXPORT
  26.  
  27.                 IMPORT    DRVROpen, DRVRPrime, DRVRControl, DRVRStatus, DRVRClose
  28.  
  29. Header
  30.         dc.w    drvrFlags + drvrSystemFlags
  31.         DC.W    0        ; no run time
  32.         DC.W    0        ; no events
  33.         DC.W    0        ; no menu
  34.  
  35. ; Entry point offset table to the procs: Open, Prime, Control, Status, Close
  36.         DC.W    MyOpen        - DRVREntry  ; open routine
  37.         DC.W    MyPrime        - DRVREntry  ; prime
  38.         DC.W    MyControl    - DRVREntry  ; control
  39.         DC.W    MyStatus    - DRVREntry  ; status
  40.         DC.W    MyClose        - DRVREntry  ; close
  41.  
  42. ; Title
  43. ;        include three pad bytes so we can re-number the driver
  44.         DC.B    14                    ;Length byte
  45.         DC.B    '.USB--Print---'    ;Pad to odd # of chars, so 1st routine
  46.                                     ;  will be word-aligned.
  47.  
  48. ; Push the address of the routine we wish to call and jump to the glue
  49. ; which sets up the parameters and calls the actual driver implementation
  50. MyOpen        PEA        DRVROpen
  51.             bra.s    MyGlue
  52. MyPrime        PEA        DRVRPrime
  53.             bra.s    MyGlue
  54. MyControl    PEA        DRVRControl
  55.             bra.s    MyGlue
  56. MyStatus    PEA        DRVRStatus
  57.             bra.s    MyGlue
  58. MyClose        PEA        DRVRClose
  59.  
  60. MyGlue
  61.             MOVEM.L    A0/A1,-(A7)                ; save params to the routine
  62.             CLR.W    -(A7)                    ; make room for result
  63.             MOVE.L    A0,-(A7)                ; pass the parameter block
  64.             MOVE.L    A1,-(A7)                ; pass the device control entry
  65.             MOVEA.L    $0012(A7),A0            ; address of routine to jump to
  66.             JSR        (A0)                    ; do it
  67.             MOVE.W    (A7)+,D0                ; get result
  68.             MOVEM.L    (A7)+,A0/A1                ; restore device parameters
  69.             ADDQ.W    #4,A7                    ; pop routine address to clean up
  70. ;            tst.w    IOParam.ioResult(a0)
  71. ;            beq.s    IOComplete
  72.             BTST    #10,IOParam.ioTrap(A0)    ; test for an async call
  73.             BNE.S    Done                    ; if not async, we're done
  74. IOComplete
  75.             SUBQ.W    #4,A7                    ; else get the JIODone vector
  76.             _LMGetJIODone                    ; so we can jump to it.
  77. Done
  78.             RTS        
  79. ;
  80. ;
  81. ;    Change History:
  82. ;        24 Ar 1998,    oja:    pass the error in D0
  83. ;
  84. DRVRDONE    PROC    EXPORT
  85.             
  86.             MOVE.L    4(sp),a0                ; pass the parameter block
  87.             MOVE.L    8(sp),a1                ; pass the device control entry
  88.             MOVE.W    12(sp),d0
  89.             SUBQ.W    #4,A7                    ; get the JIODone vector
  90.             _LMGetJIODone                    ; jump to it.
  91.             
  92.             RTS
  93.  
  94.             ENDPROC
  95.     END
  96.     
  97.